const { defineConfig } = require('@vue/cli-service')

const defaultSettings = require('./src/settings.js')

function resolve(dir) {
  return path.join(__dirname, dir)
}

const name = defaultSettings.title || '川仪流量选型报价系统' // page title

module.exports = defineConfig({
  transpileDependencies: true,
  lintOnSave:false,
  configureWebpack: {
    resolve: {
      fallback: { path: false },
    },
  },
  devServer: {
    //proxy: 'http://localhost:4000'
    proxy: {
      '/api': {
        target: 'http://120.77.238.75:9001',
        ws: true,
        changeOrigin: true,
        logLevel:"debug", //打印日志 ，查看代理地址 x-real-url:
        pathRewrite:{
          "^/api":''
        },
        onProxyRes(ProxyRes,response){
          const realUrl = new URL(response.url,"http://120.77.238.75:9001").href
          ProxyRes.headers['x-real-url'] = realUrl
        },
      },
      // '/foo': {
      //   target: '<other_url>'
      // }
    }
  },
  chainWebpack: (config) => {
    config.plugin('define').tap((definitions)=>{
      Object.assign(definitions[0],{
        __VUE_OPTIONS_API__:'true',
        __VUE_PROD_DEVTOOLS__:'false',
        __VUE_PROD_HYDRATION_MISMATCH_DETAILS__:'false'
      })
      return definitions
    })
  },
}
)
